﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyHospital.DAL;

namespace MyHospital.web
{
    public partial class MasterPage : System.Web.UI.MasterPage
    {
        MyHospitalDataContext db = new MyHospitalDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
           
            //Session["PatientName"] = "aaa";

            if (Session["AdminId"] != null || Session["PatientID"] != null)
            {
                if (Session["AdminId"] != null)
                {
                    var result=(from r in db.Admin
                               where r.adminId== (int)Session["AdminId"]
                               select r).FirstOrDefault();
                    Session["AdminName"] = result.account;
                    lblWelcome.Text = "您好，" + Session["AdminName"].ToString();
                    
                    ksgl.Visible = true;
                    ysgl.Visible = true;
                    jbgl.Visible = true;
                    timegl.Visible = true;
                    tjfx.Visible = true;
                    lnkbtnPwd.Visible = true;
                    lnkbtnRegister.Visible = false;
                    lnkbtnLogin.Visible = false;
                    lnkbtnCart.Visible = false;
                    lnkbtnSiteMap.Visible = false;
                    lnkbtnBook.Visible = false;
                }
                else if (Session["PatientID"] != null)
                {
                  /*  var result = (from r in db.Patient
                                  where r.patId == (int)Session["PatientID"]
                                  select r).FirstOrDefault();
                    if (result != null)
                    {
                        Session["PatientName"] = result.patName;
                    }*/
                    
                    lblWelcome.Text = "您好，" + Session["PatientName"].ToString();
                    lnkbtnPwd.Visible = true;
                    lnkbtnOrder.Visible = true;
                    lnkbtnLogin.Visible = false;
                }
                lnkbtnLogout.Visible = true;
            }
        }

        protected void lnkbtnLogout_Click(object sender, EventArgs e)
        {
            Session.Clear();
            Response.Redirect("index.aspx");
        }
    }
}